#coding:utf-8
import torndb
import json
db=torndb.Connection('10.6.5.234:3306','bw_hotel','root',"uvhxqaMjMPjhJZw3")
# a=db.query('select CVHotelID from BWWeb_VHotel_Map where PVHotelID = 10000000')
# list = []
# for i in a:
#     # print i
#     list.append(json.dumps(i["CVHotelID"]))
# print ",".join(list)
# b=db.query('select CVHotelID from BWWeb_VHotel_Map where PVHotelID in ({a_floor})'.format(a_floor=",".join(list)))
# # print b
# list2 = []
# for j in b:
#     list2.append(json.dumps(j["CVHotelID"]))
# print list2


all_hotel = []
def hotel_check(hotel_list):
    list = []
    hotel_sql = db.query('select CVHotelID from BWWeb_VHotel_Map where PVHotelID in ({a_floor})'.format(a_floor=hotel_list))
    print 'True'
    if len(hotel_sql) == 0:
        return all_hotel
    for i in hotel_sql:
        list.append(json.dumps(i["CVHotelID"]))
    hotel_list = ",".join(list)
    all_hotel.extend(list)
    return hotel_check(hotel_list)

print hotel_check(10000000)
